/*
 * @Author: TT-hzy 
 * @Date: 2024-06-27 16:49:50
 * @LastEditors: TT-hzy 
 * @LastEditTime: 2024-07-05 16:28:37
 * @Description: 
 */


// 'use strict';

// module.exports = app => {
//   const { STRING, INTEGER, DATE } = app.Sequelize;
//   const User = app.model.define('users', {
//     id: { type: INTEGER, primaryKey: true, autoIncrement: true },
//     name: STRING(30),
//     age: INTEGER,
//     created_at: DATE,
//     updated_at: DATE,
//     username: STRING(30),
//     password: STRING(30),

//   });
//   return User;
// };




import {
  Table,
  Column,
  Model,
  DataType,
  PrimaryKey,
  AutoIncrement,
  AllowNull,
} from 'sequelize-typescript';


@Table({
  modelName: 'users',
  underscored: true,

})

class User extends Model<User> {


  @PrimaryKey
  @AutoIncrement
  @Column({
    type: DataType.INTEGER,
    comment: "用户ID",
  })
  id: number;


  @Column({
    type: DataType.STRING(30),
    comment: "用户名",
  })
  name: string;

  @Column({
    type: DataType.INTEGER,
    comment: "年龄",
  })
  age: number;

  @Column({
    type: DataType.DATE,
    comment: "创建时间",
  })
  createdAt: Date;

  @Column({
    type: DataType.DATE,
    comment: "更新时间",
  })
  updatedAt: Date;

  @AllowNull
  @Column({
    type: DataType.STRING(30),
    comment: "密码",
    defaultValue: "123456",
  })
  password: string;


}

export default () => User;